﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Koonsoft.CustomerService.DAL;
using Koonsoft.CustomerService.Entity;

namespace Koonsoft.CustomerService.BLL
{
    public class EmployeeBLL
    {
        private EmployeeDAL _dal = null;

        protected EmployeeDAL DAL
        {
            get
            {
                if (_dal == null)
                {
                    _dal = new EmployeeDAL();
                }

                return _dal;
            }
        }

        /// <summary>
        /// login
        /// </summary>
        /// <param name="account"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool Login(string account, string password)
        {
            List<Employee> employees = DAL.GetEmpolyeeByLoginAccount(account);

            if (employees == null)
            {
                return false;
            }

            var employee = employees[0];

            if (password != employee.Password)
            {
                return false;
            }

            return true;
        }
        public bool UpdagtePassword(string userName, string oldPass, string newPass)
        {
            return DAL.UpdagtePassword(userName, oldPass, newPass);
        }
    }
}
